<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>lib/VisibleGridZone.js - Documentation</title>

    <script src="scripts/prettify/prettify.js"></script>
    <script src="scripts/prettify/lang-css.js"></script>
    <!--[if lt IE 9]>
      <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->
    <link type="text/css" rel="stylesheet" href="styles/prettify.css">
    <link type="text/css" rel="stylesheet" href="styles/jsdoc.css">
</head>
<body>

<input type="checkbox" id="nav-trigger" class="nav-trigger" />
<label for="nav-trigger" class="navicon-button x">
  <div class="navicon"></div>
</label>

<label for="nav-trigger" class="overlay"></label>

<nav>
    <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="LabelElement.html">LabelElement</a></li><li><a href="module-labeling-utils-GridPolygon.html">GridPolygon</a></li><li><a href="module-mgrs-utils-NonPolarGridZone.html">NonPolarGridZone</a><ul class='methods'><li data-type='method'><a href="module-mgrs-utils-NonPolarGridZone.html#toPolygon">toPolygon</a></li><li data-type='method'><a href="module-mgrs-utils-NonPolarGridZone.html#toPolyline">toPolyline</a></li></ul></li><li><a href="module-mgrs-utils-VisibleGridZone.html">VisibleGridZone</a><ul class='methods'><li data-type='method'><a href="module-mgrs-utils-VisibleGridZone.html#getCenterLabel">getCenterLabel</a></li><li data-type='method'><a href="module-mgrs-utils-VisibleGridZone.html#getLabels">getLabels</a></li></ul></li></ul><h3>Modules</h3><ul><li><a href="module-constants.html">constants</a></li><li><a href="module-geometry-utils.html">geometry-utils</a><ul class='methods'><li data-type='method'><a href="module-geometry-utils.html#~extentToPolygon">extentToPolygon</a></li><li data-type='method'><a href="module-geometry-utils.html#~pointToGeographic">pointToGeographic</a></li><li data-type='method'><a href="module-geometry-utils.html#~polygonToPolyline">polygonToPolyline</a></li><li data-type='method'><a href="module-geometry-utils.html#~toGeographic">toGeographic</a></li><li data-type='method'><a href="module-geometry-utils.html#~toWebMercator">toWebMercator</a></li></ul></li><li><a href="module-labeling-utils.html">labeling-utils</a><ul class='methods'><li data-type='method'><a href="module-labeling-utils.html#~distanceFromMapEdge">distanceFromMapEdge</a></li><li data-type='method'><a href="module-labeling-utils.html#~getScreenSize">getScreenSize</a></li><li data-type='method'><a href="module-labeling-utils.html#~getWidthOfText">getWidthOfText</a></li><li data-type='method'><a href="module-labeling-utils.html#~padZero">padZero</a></li><li data-type='method'><a href="module-labeling-utils.html#~screenDistanceBetweenPoints">screenDistanceBetweenPoints</a></li></ul></li><li><a href="module-mgrs-utils.html">mgrs-utils</a><ul class='methods'><li data-type='method'><a href="module-mgrs-utils.html#~getInterval">getInterval</a></li><li data-type='method'><a href="module-mgrs-utils.html#~handle100kGrids">handle100kGrids</a></li><li data-type='method'><a href="module-mgrs-utils.html#~handleIntervals">handleIntervals</a></li><li data-type='method'><a href="module-mgrs-utils.html#~handleZonePolygon">handleZonePolygon</a></li><li data-type='method'><a href="module-mgrs-utils.html#~processZonePolygons">processZonePolygons</a></li><li data-type='method'><a href="module-mgrs-utils.html#~zonesFromExtent">zonesFromExtent</a></li></ul></li></ul><h3>Externals</h3><ul><li><a href="external-Color.html">Color</a></li><li><a href="external-Extent.html">Extent</a></li><li><a href="external-Font.html">Font</a></li><li><a href="external-Geometry.html">Geometry</a></li><li><a href="external-Graphic.html">Graphic</a></li><li><a href="external-GraphicsLayer.html">GraphicsLayer</a></li><li><a href="external-Map.html">Map</a></li><li><a href="external-Point.html">Point</a></li><li><a href="external-Polygon.html">Polygon</a></li><li><a href="external-Polyline.html">Polyline</a></li><li><a href="external-SpatialReference.html">SpatialReference</a></li><li><a href="external-TextSymbol.html">TextSymbol</a></li></ul>
</nav>

<div id="main">
    
    <h1 class="page-title">lib/VisibleGridZone.js</h1>
    

    



    
    <section>
        <article>
            <pre class="prettyprint source linenums"><code>/**
 *  @fileOverview Contains the VisibleGridZone class used by MGRS GridOverlay widgets.
 *  @author Esri
 */

define(["dojo/_base/declare", "./GridPolygon"], function(declare, GridPolygon) {

  /**
   * @class module:mgrs-utils~VisibleGridZone
   * @classdesc A VisibleGridZone object is derived by taking a NonPolarGridZone object and displaying it on screen.  It holds all the parameters needed to draw and label the visible portion of the NonPolarGridZone.
   *
   * @constructor
   * @param {Object}                                properties                  The VisibleGridZone constructor takes an object as described below
   * @param {external:Polyline}                     properties.polyline         The visible border of the grid zone
   * @param {external:Polygon}                      properties.polygon          The visible area of the grid zone
   * @param {Number}                                [properties.offset=0]       The non-normalized x-offset of the grid
   * @param {module:mgrs-utils~NonPolarGridZone}    properties.nonPolarGridZone The NonPolarGridZone object that is related to this VisibleGridZone object
   * @param {external:Map}                          properties.map              The Map object that the grid overlay is associated with
   * @param {module:labeling-utils~LabelParameters} properties.labelParameters  An object holding all the label parameters
   *
   * @example
   * var offset = -1; // in this case, the current longitude is in the range -540 => -180
   * var nonPolarGridZone = ZonesDictionary["42S"];
   * var zonePolygon = nonPolarGridZone.toPolygon(offset);
   *
   * // convert zonePolygon to web mercator so it can be used with the geometryEngine.intersect method
   * zonePolygon = webMercatorUtils.geographicToWebMercator(zonePolygon);
   * var clippedPolygon = geometryEngine.intersect(zonePolygon, map.extent);
   *
   * var labelParameters = {
   *     "xOffset": 20,
   *     "yOffset": 20,
   *     "rotation": 0,
   *     "color": new Color([0, 0, 255]),
   *     "fontFamily": "Arial, Helvetica, sans-serif",
   *     "fontSize": "18px"
   * };
   *
   * visibleGridZone = new VisibleGridZone({
   *     "map": map,
   *     "polyline": clippedPolygon,
   *     "polygon": zonePolygon,
   *     "offset": 0,
   *     "nonPolarGridZone": nonPolarGridZone,
   *     "labelParameters": labelParameters
   * });
   */
  return declare(null, /** @lends module:mgrs-utils~VisibleGridZone# */ {

    /** The clipped portion of the grid zone polyline that represents the visible border
     * @type {external:Polyline}
     */
    "polyline": null,

    /** The clipped portion of the grid zone polygon that represents the visible area
     * @type {external:Polygon}
     */
    "polygon": null,

    /** The non-normalized x-offset of the grid. This allows for grid overlays to be drawn in wraparound mound (i.e. spanning accross the Dateline).
     * For Example: An offset of 0 means the x-coordinate is in the longitude range of -180 => 180, and an offset of -1 correlates to the range of -540 => -180.
     * @type {Number}
     */
    "offset": null,

    /** The original NonPolarGridZone object, before it was clipped for visible area
     * @type {module:mgrs-utils~NonPolarGridZone}
     */
    "nonPolarGridZone": null,

    /** The Map object that this grid overlay is associated with
     * @type {external:Map}
     */
    "map": null,

    constructor: function(args) {
      // offset must be an integer
      this.offset = Math.round(args.offset);
      this.polyline = args.polyline;
      this.polygon = args.polygon;
      this.nonPolarGridZone = args.nonPolarGridZone;
      this.map = args.map;

      // construct a GridPolygon, which is used as the label manager
      var gridPolygonArgs = {
        "clippedPolygon": this.polygon,
        "unclippedPolygon": this.nonPolarGridZone.toPolygon(args.offset),
        "map": this.map,
        "xmin": this.nonPolarGridZone.extent.xmin,
        "ymin": this.nonPolarGridZone.extent.ymin,
        "xmax": this.nonPolarGridZone.extent.xmax,
        "ymax": this.nonPolarGridZone.extent.ymax,
        "minMaxType": "degrees",
        "utmZone": 0,
        "text": this.nonPolarGridZone.id,
        "labelParameters": args.labelParameters,
      };
      this.gridPolygon = new GridPolygon(gridPolygonArgs);
    },

    /**
     * Returns an array of TextSymbol graphics that represent labels for the VisibleGridZone
     * @return {external.TextSymbol[]} An array of TextSymbol objects used for labeling the VisibleGridZone
     */
    getLabels: function() {
      return this.gridPolygon.getLabels(true);
    },

    /**
     * Returns the TextSymbol graphic that represents the label at the center of the NonPolarGridZone.
     * @return {external:TextSymbol} The TextSymbol object representing the center label of the VisibleGridZone
     */
    getCenterLabel: function() {
      return this.gridPolygon.getCenterLabel();
    }

  });
});</code></pre>
        </article>
    </section>




</div>

<br class="clear">

<footer>
    Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0</a> using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer>

<script>prettyPrint();</script>
<script src="scripts/linenumber.js"></script>
</body>
</html>
